(define (abs x)
  (if (< x 0) (- x) x))

(define (cube-root x)
  (define (good-enough? guess next-guess tolerance)
    (< (/ (abs (- guess next-guess)) guess) tolerance))
  (define (improve guess)
    (/ (+ (/ x (* guess guess)) (* 2 guess)) 3))
  (define (cube-root-iter guess)
    (define next-guess (improve guess))
    (if (good-enough? guess next-guess 0.001) guess
        (cube-root-iter next-guess)))
  (cube-root-iter 1.0))
